<template>
	<view class="padding">
		<view class="bg padding radius">
			<view class="flex justify-between align-center">
				<view class="flex">
					<view class="">
						<image :src="order.appointInformation?order.appointInformation.img:'../../static/logo.png'"
							mode="aspectFill" style="width: 120rpx;height: 120rpx;border-radius: 10upx;"></image>
					</view>
					<view class="margin-left-xs">
						<view class="u-flex-1">
							<view class="text-lg text-bold" style="width: 280rpx;" v-if="order.appointInformation">
								{{order.appointInformation.serviceName}}
							</view>
							<view class="flex-wrap flex margin-top-xs" v-if="order.appointInformation">
								<view class="flex align-center margin-right-xs text-sm" style="color: #999999;"
									v-for="(ite,ind) in order.appointInformation.tags" :key="ind">
									{{ite}}
									<view style="width: 1rpx;height: 21upx;background: #CCCCCC;margin-left: 10upx;"
										v-if="order.appointInformation.tags.length-1!=ind"></view>
								</view>
							</view>
						</view>
						<view class="text-bold" style="color: #FF2D01;font-size: 40upx;margin-top: 6rpx;">
							<text style="font-size: 26upx;">预计收益:</text><text style="font-size: 32rpx;">￥</text>
							{{order.payMoney}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bg padding radius margin-top">
			<view class="text-lg text-bold">
				服务信息
			</view>
			<view class=" margin-right-xs">
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation">
					<view class="" style="width: 180upx;color: #999999;">期望就诊时间</view>
					<view style="font-weight: bold;">{{order.appointInformation.hopeTime}}</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation">
					<view class="" style="width: 150upx;color: #999999;">就诊医院</view>
					<view style="font-weight: bold;">{{order.appointInformation.hospitalName}}</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.departmentName">
					<view class="" style="width: 150upx;color: #999999;">就诊科室</view>
					<view>{{order.appointInformation.departmentName}}</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.badNo">
					<view class="" style="width: 150upx;color: #999999;">就诊床号</view>
					<view>{{order.appointInformation.badNo}}</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.nursingNeeds">
					<view class="" style="width: 150upx;color: #999999;">护理需求</view>
					<view>{{order.appointInformation.nursingNeeds}}</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.selfAbility">
					<view class="" style="width: 150upx;color: #999999;">自理能力</view>
					<view>{{order.appointInformation.selfAbility}}</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.symptom">
					<view class="" style="width: 150upx;color: #999999;">病症</view>
					<view>{{order.appointInformation.symptom}}</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.serviceNum">
					<view class="" style="width: 150upx;color: #999999;">服务天数</view>
					<view>{{order.appointInformation.serviceNum}}天</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.patientInfo && order.state != 4 && order.state != 3">
					<view class="" style="width: 150upx;color: #999999;">就诊人</view>
					<view>{{order.appointInformation.patientInfo.realName}}</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.patientInfo && order.state != 4 && order.state != 3">
					<view class="" style="width: 150upx;color: #999999;">就诊关系</view>
					<view>{{order.appointInformation.patientInfo.relationship}}</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.patientInfo && order.state != 4 && order.state != 3"
					@click="bindphone(order.appointInformation.patientInfo.phone)">
					<view class="" style="width: 150upx;color: #999999;">就诊人电话</view>
					<view class="text-white">
						{{order.appointInformation.patientInfo.phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2")}}
						<u-icon name="phone"></u-icon>
					</view>
				</view>
				<view class="flex justify-between margin-top-lg"
					v-if="order.state != 4 && order.appointInformation && order.appointInformation.phone && order.state != 3"
					@click="bindphone(order.appointInformation.phone)">
					<view class="" style="width: 150upx;color: #999999;">联系电话</view>
					<view class="text-white">
						{{order.appointInformation.phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2")}}
						<u-icon name="phone"></u-icon>
					</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.patientInfo && order.appointInformation.patientInfo.emergencyPhone && order.state != 4 && order.state != 3"
					@click="bindphone(order.appointInformation.patientInfo.emergencyPhone)">
					<view class="" style="width: 200upx;color: #999999;">紧急联系人</view>
					<view class="text-white">
						{{order.appointInformation.patientInfo.emergencyPhone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2")}}
						<u-icon name="phone"></u-icon>
					</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.drugsType">
					<view class="" style="width: 150upx;color: #999999;">药物类型</view>
					<view class="text-white">{{order.appointInformation.drugsType}}
					</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.drugsName">
					<view class="" style="width: 150upx;color: #999999;">药物名称</view>
					<view class="text-white">{{order.appointInformation.drugsName}}
					</view>
				</view>
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation && order.appointInformation.reportType">
					<view class="" style="width: 150upx;color: #999999;">报告信息</view>
					<view class="text-white">{{order.appointInformation.reportType}}
					</view>
				</view>
				<view class="flex justify-between margin-top-lg"
					v-if="order.appointInformation && order.appointInformation.userDetailsAddress && order.appointInformation.serviceType == 1 && order.state != 4 && order.state != 3"
					@click="gomap(order.appointInformation.userLat,order.appointInformation.userLng,order.appointInformation.userDetailsAddress)">
					<view class="" style="width: 150upx;color: #999999;">接送地址</view>
					<view class="text-white">
						{{order.appointInformation.userProvince}}
						{{order.appointInformation.userCity}}
						{{order.appointInformation.userDistrict}}
						{{order.appointInformation.userDetailsAddress}}
						<u-icon name="map"></u-icon>
					</view>
				</view>
				<view class="flex justify-between margin-top-lg"
					v-if="order.appointInformation && order.appointInformation.userName && order.state != 4 && order.state != 3">
					<view class="" style="width: 150upx;color: #999999;">收件人</view>
					<view class="text-white">{{order.appointInformation.userName}}
					</view>
				</view>
				<view class="flex justify-between margin-top-lg"
					v-if="order.appointInformation && order.appointInformation.userPhone && order.state != 4 && order.state != 3"
					@click="bindphone(order.appointInformation.userPhone)">
					<view class="" style="width: 150upx;color: #999999;">收件人号码</view>
					<view class="text-white">
						{{order.appointInformation.userPhone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2")}}
						<u-icon name="phone"></u-icon>
					</view>
				</view>
				<view class="flex justify-between margin-top-lg"
					v-if="order.appointInformation && order.appointInformation.userDetailsAddress && order.appointInformation.serviceType != 1 && order.state != 4 && order.state != 3"
					@click="gomap(order.appointInformation.userLat,order.appointInformation.userLng,order.appointInformation.userDetailsAddress)">
					<view class="" style="width: 150upx;color: #999999;">收件地址</view>
					<view class="text-white">
						{{order.appointInformation.userProvince}}
						{{order.appointInformation.userCity}}
						{{order.appointInformation.userDistrict}}
						{{order.appointInformation.userDetailsAddress}}
						<u-icon name="map"></u-icon>
					</view>
				</view>
				<view class="flex justify-end"
					v-if="order.appointInformation &&  order.appointInformation.userDetailsAddress && order.appointInformation.serviceType != 1 && order.state != 4 && order.state != 3"
					@click="copyAddress(order.appointInformation)">
					<view class=""
						style="padding: 5rpx 10rpx 5rpx 10rpx; border-radius: 24rpx;border: 1rpx solid #999999;color: #999999;font-size: 24rpx;">
						一键复制
					</view>

				</view>
				<view class="margin-top-lg" v-if="order.appointInformation && order.appointInformation.imgRemarks && order.state == 5" style="width: 165rpx;color: #999999;">图片资料</view>
				<view class="margin-top-lg flex flex-wrap" v-if="order.appointInformation && order.appointInformation.imgRemarks && order.state == 5">
					<image @click="peiveImgs(index,order.appointInformation.imgRemarks.split(','))" :src="item" style="width: 195rpx;height: 195rpx;border-radius: 10rpx;margin-right: 10rpx;margin-bottom: 10rpx;" v-for="(item,index) in order.appointInformation.imgRemarks?order.appointInformation.imgRemarks.split(','):[]" mode=""></image>
				</view>
				<view class=" margin-top-lg">
					<view class="" style="width: 165rpx;color: #999999;">特殊需求</view>
					<view class="text-white margin-top" style="font-size: 30rpx;">
						{{order.appointInformation && order.appointInformation.remarks?order.appointInformation.remarks:'暂无'}}
					</view>
				</view>

			</view>
		</view>
		<view class="bg padding radius margin-top" style="margin-bottom: 140rpx;">
			<view class="text-lg text-bold">
				订单信息
			</view>
			<view class="margin-right-xs">
				<view class="flex justify-between margin-top-lg" v-if="order.appointInformation">
					<view class="" style="width: 150upx;color: #999999;">服务类型</view>
					<view class="text-white">{{order.appointInformation.serviceName}}</view>
				</view>
				<view class="flex justify-between margin-top-lg">
					<view class="" style="width: 150upx;color: #999999;">订单编号</view>
					<view class="text-white flex align-center">{{order.ordersNo}}
						<image src="../static/copy.png" style="width: 45rpx;height: 45rpx;margin-left: 5upx;"
							@click.stop="copyClick(order.ordersNo)"></image>
					</view>
				</view>
				<view class="flex justify-between margin-top-lg">
					<view class="" style="width: 150upx;color: #999999;">下单时间</view>
					<view class="text-white">{{order.createTime}}</view>
				</view>
			</view>
		</view>
		<block v-if="!titleName">
			<view class="flex tabber padding-top-sm padding-bottom-sm align-center margin-right-xs padding-right"
				v-if="order.state ==1||order.state==4||order.state==5">
				<!-- <u-button v-if="order.state == 4" :custom-style="customStyle1" shape="circle" :plain="true"
					@click="takeOrder(order,3)">接单</u-button> -->
				<u-button v-if="order.state == 5 && isShowCloseBtn" :custom-style="customStyle" shape="circle" :plain="true"
					@click="cleanOrder(order,3)">取消接单</u-button>
				<u-button v-if="order.state == 5" :custom-style="customStyle1" shape="circle" :plain="true"
					@click="openOrder(order)">转单</u-button>
				<u-button v-if="order.state == 1" :custom-style="customStyle1" shape="circle" :plain="true"
					@click="Ordersure()">完成服务</u-button>
				<u-button v-if="order.state == 5" :custom-style="customStyle1" shape="circle" :plain="true"
					@click="cancelOrder(order,1)">开始服务</u-button>
			</view>
		</block>
		<block v-else>
			<view class="" style="position: fixed;right: 30rpx;bottom: 100rpx;">
				<u-button v-if="order.state == 4" :custom-style="customStyle2" shape="circle" :plain="true"
					@click="takeOrder(order,3)">接单</u-button>
			</view>
		</block>


		<!-- 确认码弹框 -->
		<view class="boxtk" v-if="reverTrue">
			<view class="whitebox padding">
				<view class="flex justify-between align-center">
					<view style="font-size:38upx;color:#333333" class="text-bold">确认码</view>
					<view @click="bindclose(1)">
						<image src="/static/images/msg/close.png" style="width:44upx;height:44upx;"></image>
					</view>
				</view>
				<view style="margin-top:59upx;">
					<input placeholder="请输入确认码" name="input" maxlength="10" v-model="codeNum" type="number"
						style="background: #F2F2F2;height:100upx;padding:30upx"></input>
				</view>
				<view class="btn" @click="cancelOrder(order,2)">确定</view>
			</view>
		</view>

		<!-- 转单弹框 -->
		<view class="boxtk" v-if="orderTrue">
			<view class="whitebox padding">
				<view class="flex justify-between align-center">
					<view style="font-size:38upx;color:#333333" class="text-bold">转单人手机号码</view>
					<view @click="bindclose(2)">
						<image src="/static/images/msg/close.png" style="width:44upx;height:44upx;"></image>
					</view>
				</view>
				<view style="margin-top:59upx;">
					<input placeholder="请输入转单人手机号码" name="phone" maxlength="11" v-model="phone" type="number"
						style="background: #F2F2F2;height:100upx;padding:30upx"></input>
				</view>
				<view class="btn" @click="giveOrder(order)">确定</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				customStyle: {
					color: '#999999',
					border: '2rpx solid #999999',
					// backgroundColor: '#1E1F31',
					border: "8rpx",
					width: '180rpx',
					height: '54rpx',
					margin: "0 0 0 20rpx"
				},
				customStyle1: {
					color: '#fff',
					// border: '2rpx solid #557EFD',
					backgroundColor: '#557EFD',
					border: "8rpx",
					width: '180rpx',
					height: '54rpx',
					margin: "0 0 0 20rpx"
				},
				customStyle2: {
					color: '#fff',
					// border: '2rpx solid #557EFD',
					backgroundColor: '#557EFD',
					border: "8rpx",
					width: '100rpx',
					height: '100rpx',
					borderRidus: '50%',
					// margin: "0 0 0 20rpx",
				},
				id: '',
				order: [],
				isTrue: 0,
				vipMoney: '',
				data: [],
				price: '',
				codeNum: '',
				codeIndex: 0,
				reverTrue: false,
				startImgs: [],
				startImg: '',
				endImgs: [],
				endImg: '',
				orderTrue: false,
				phone: '',
				titleName: "",
				isShowCloseBtn:false,
			}
		},
		onLoad(e) {
			this.isShowCloseBtn = uni.getStorageSync('isShowCloseBtn')?uni.getStorageSync('isShowCloseBtn'):false
			this.isTrue = e.isTrue
			if (e.name) {
				uni.setNavigationBarTitle({
					title: e.name
				})
				this.titleName = e.name
			} else {
				uni.setNavigationBarTitle({
					title: '订单详情'
				})
			}
			if (e.id) {
				this.id = e.id
				this.getOrder()
			}

		},
		methods: {
			//预览图片
			peiveImgs(index,imgs){
				uni.previewImage({
					current:index,
					urls:imgs
				})
			},
			//复制收件信息
			copyAddress(addressInfo) {
				let datas = addressInfo.userName + ' ' + addressInfo.userPhone + ' ' + addressInfo.userProvince + '' +
					addressInfo.userCity + '' + addressInfo.userDistrict + '' + addressInfo.userDetailsAddress
				uni.setClipboardData({
					data: datas,
					success: function() {
						that.$queue.showToast('地址信息复制成功')
					}
				})
			},
			// 取消订单
			cleanOrder(e, status) {
				let that = this
				let data = {
					id: e.ordersId,
					status
				}
				uni.showModal({
					title: '提示',
					content: '确定要取消订单吗？',
					success: function(res) {
						if (res.confirm) {
							if (e.ordersType == 1) { //ordersType:1陪诊订单 2：陪护订单
								that.$Request.getT('/app/orders/rideCancelOrder', {
									orderId: e.ordersId
								}).then(res => {
									if (res.code == 0) {
										that.reverTrue = false
										that.page = 1
										that.getOrder()
										uni.showToast({
											title: '订单已取消',
											icon: 'none'
										})
									} else {

										that.$queue.showToast(res.msg);
									}
								})
							} else {
								that.$Request.get('/app/orders/cancelOrder', data).then(res => {
									if (res.code == 0) {
										that.reverTrue = false
										that.page = 1
										that.getOrder()
										uni.showToast({
											title: '订单已取消',
											icon: 'none'
										})
									} else {

										that.$queue.showToast(res.msg);
									}
								})
							}

						}
					},
				})
			},
			gomap(lat, lng, userDetailsAddress) {
				uni.openLocation({
					latitude: Number(lat), //要去的纬度-地址       
					longitude: Number(lng), //要去的经度-地址
					name: userDetailsAddress, //地址名称
					address: userDetailsAddress, //详细地址名称
					success: function() {
						console.log('导航成功');
					},
					fail: function(error) {
						console.log(error)
					}
				})
			},
			//转单弹框
			openOrder() {
				this.phone = ''
				this.orderTrue = true
			},
			// 拨打电话
			bindphone(phone) {
				let that = this
				uni.showModal({
					title: '提示',
					content: '是否拨打电话',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定', phone);
							uni.makePhoneCall({
								phoneNumber: phone //仅为示例
							});
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			copyClick(copy) {
				uni.setClipboardData({
					data: copy,
					success: function(res) {
						uni.getClipboardData({
							success: function(res) {
								uni.showToast({
									title: "复制成功",
									icon: 'none',
								});
							},
						});
					},
				});
			},
			// 查看图片
			saveImg(imgs, index) {
				if (this.LBSelect) {
					if (index == this.LBIndex - 1) {
						return;
					}
				}
				// console.log(imgs)
				let that = this;
				let imgArr = imgs
				// imgArr.push(imgs);
				// //预览图片
				uni.previewImage({
					urls: imgArr,
					current: imgArr[index]
				});
			},
			removeImg(index, state) {
				if (state == 1) {
					this.startImgs.splice(index, 1)
				} else if (state == 2) {
					this.endImgs.splice(index, 1)
				}
			},
			//关闭弹框  1 确认码  2 转单弹框
			bindclose(index) {
				if (index == 1) {
					this.reverTrue = false
				} else if (index == 2) {
					this.orderTrue = false
				}
			},
			Ordersure() {
				// if (this.endImgs.length == 0) {
				// 	uni.showToast({
				// 		title: '请上传服务后照片',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// if (this.endImgs.length <= 3) {
				// 	uni.showToast({
				// 		title: '图片最少四张',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				this.codeNum = ''
				// this.codeIndex = index;
				this.reverTrue = true
			},
			copyOrder(order) {
				let that = this;
				uni.setClipboardData({
					data: order,
					success: function() {
						that.$queue.showToast('复制成功')
					}
				})
			},
			// 一键导航
			bindGps(latitude, longitude, name) {
				uni.openLocation({
					latitude: Number(latitude), //要去的纬度-地址       
					longitude: Number(longitude), //要去的经度-地址
					name: name, //地址名称
					address: name, //详细地址名称
					success: function() {
						console.log('导航成功');
					},
					fail: function(error) {
						console.log(error)
					}
				});
			},

			getOrder() {
				uni.showLoading({
					title: '加载中...',
					icon: 'none'
				});
				let data = {
					id: this.id
				}
				this.$Request.get('/app/orders/queryOrders', data).then(res => {
					uni.hideLoading();
					if (res.code == 0) {
						
						let rate = uni.getStorageSync('rate')
						if(res.data.state==5){
							res.data.payMoney = parseFloat(parseFloat(res.data.payMoney) * parseFloat(res.data.rateProportion))
								.toFixed(2);
						}else{
							res.data.payMoney = parseFloat(parseFloat(res.data.payMoney) * parseFloat(rate))
								.toFixed(2);
						}
						
						this.order = res.data
						if (this.order.appointInformation.tags) {
							this.order.appointInformation.tags = this.order.appointInformation.tags.split("|");
						}
						// if (this.order.startImg) {
						// 	this.order.startImg = this.order.startImg.split(",");
						// }
						// if (this.order.endImg) {
						// 	this.order.endImg = this.order.endImg.split(",");
						// }
						// if (this.order.carPhone) {
						// 	let carPhone = this.order.carPhone
						// 	this.order.carPhone = carPhone.substring(0, 3) + "****" + carPhone.substr(carPhone
						// 		.length - 4);
						// }
						// this.price = (res.data.orderTaking.oldMoney * res.data.orderNumber)
						// 	.toFixed(2)
						// this.vipMoney = (res.data.orderTaking.money * res.data.orderNumber - res.data.payMoney * 1)
						// 	.toFixed(2)
					}
				})
			},
			//转单
			giveOrder(e) {
				let that = this
				if (!that.phone) {
					uni.showToast({
						title: '请输入转单人手机号码',
						icon: 'none'
					})
					return
				}
				uni.showModal({
					title: '提示',
					content: '确定转单吗？',
					success: function(res) {
						if (res.confirm) {
							that.orderTrue = false
							let data = {
								ordersId: e.ordersId,
								phone: that.phone,
							}
							that.$Request.post('/app/orders/giveOrdersUser', data).then(ret => {
								if (ret.code == 0) {
									that.phone = ""
									uni.showToast({
										title: '转单成功',
										icon: 'none'
									})
									setTimeout(function() {
										uni.navigateBack()
									}, 1000)
								} else {
									that.$queue.showToast(ret.msg);
								}
							})
						}
					},
				})

			},
			// 取消订单
			cancelOrder(e, status) {
				let that = this
				if (status == 2) {
					if (!this.codeNum) {
						uni.showToast({
							title: '请输入确认码',
							icon: 'none'
						})
						return
					}
					// that.endImg = that.endImgs
					// that.endImg = that.endImg.toString()
				}
				if (status == 1) {
					// if (that.startImgs.length == 0) {
					// 	uni.showToast({
					// 		title: '请上传服务前照片',
					// 		icon: 'none'
					// 	})
					// 	return
					// }
					// if (that.startImgs.length <= 3) {
					// 	uni.showToast({
					// 		title: '图片最少四张',
					// 		icon: 'none'
					// 	})
					// 	return
					// }
					// that.startImg = that.startImgs
					// that.startImg = that.startImg.toString()
					// that.reverTrue = false
				}

				let content = ''
				if (status == 3) {
					content = '确定拒绝接单吗？'
				} else if (status == 2) {
					content = '确定订单已经完成吗？如果未完成，客户投诉将采取封号处理'
				} else if (status == 1) {
					content = '确定开始服务吗？'
				}
				uni.showModal({
					title: '提示',
					content: content,
					success: function(res) {
						if (res.confirm) {
							let data
							if (status == 3) {
								data = {
									id: e.ordersId,
									status
								}
							} else if (status == 2) {
								data = {
									id: e.ordersId,
									// endImg: that.endImg,
									code: that.codeNum,
									status

								}
							} else if (status == 1) {
								data = {
									id: e.ordersId,
									// startImg: that.startImg,
									status

								}
							}
							that.$Request.get('/app/orders/cancelOrder', data).then(res => {
								if (res.code == 0) {
									if (status == 3 || status == 1) {
										that.getOrder()
									} else if (status == 2) {
										that.codeNum = '',
											that.reverTrue = false,
											that.getOrder()
									}
								} else {
									that.$queue.showToast(res.msg)
								}
							})
						}
					},
				})

			},
			// 图片上传
			addImage(e) {

				let that = this
				uni.chooseImage({
					count: 6,
					sourceType: ['album', 'camera'],
					success: res => {
						for (let i = 0; i < res.tempFilePaths.length; i++) {
							that.$queue.showLoading("上传中...");
							uni.uploadFile({ // 上传接口
								// url: this.config("APIHOST1") + '/alioss/upload', //真实的接口地址
								url: 'https://xicheshop.xianmxkj.com/sqx_fast/alioss/upload',
								filePath: res.tempFilePaths[i],
								name: 'file',
								success: (uploadFileRes) => {
									if (e == 1) {
										console.log(JSON.parse(uploadFileRes.data).data)
										that.startImgs.push(JSON.parse(uploadFileRes.data).data)
									} else if (e == 2) {
										that.endImgs.push(JSON.parse(uploadFileRes.data).data)
									}
									uni.hideLoading();
								}
							});
						}
					}
				})
			},
			// 支付订单
			pay() {
				let that = this
				uni.showModal({
					title: '付款提示',
					content: '确认支付' + that.order.payMoney + '元吗?',
					success: function(re) {
						if (re.confirm) {
							console.log('用户点击确定');
							that.$Request.post("/app/orders/payMoney", {
								ordersId: that.order.ordersId,
							}).then(res => {
								if (res.code == 0) {
									uni.showToast({
										title: '支付成功'
									})
									setTimeout(function() {
										uni.navigateBack()
									}, 1000)
								} else {
									uni.showToast({
										title: res.msg,
										icon: 'none'
									})
								}
							});
						} else if (re.cancel) {
							console.log('用户点击取消');
						}
					}

				})

			},
			startOrder(e, status) {
				let that = this
				if (that.startImgs.length == 0) {
					uni.showToast({
						title: '请上传服务前照片',
						icon: 'none'
					})
					return
				}
				if (that.startImgs.length <= 3) {
					uni.showToast({
						title: '图片最少四张',
						icon: 'none'
					})
					return
				}
				that.startImg = that.startImgs
				that.startImg = that.startImg.toString()

				uni.showModal({
					title: '提示',
					content: '确定接单吗？',
					success: function(res) {
						if (res.confirm) {
							let data = {
								ordersId: e.ordersId,
								startImg: that.startImg,
								status
							}
							that.$Request.post("/app/orders/cancelOrder", data).then(ret => {
								if (ret.code == 0) {
									uni.showToast({
										title: '服务开始',
										icon: 'none'
									})
									setTimeout(function() {
										uni.switchTab({
											url: '/pages/order/index'
										})
									}, 1000);
								} else {
									uni.showToast({
										title: ret.msg,
										icon: 'none'
									})
								}
							});
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			},
			//接单
			takeOrder(e, index) {
				let that = this
				uni.showModal({
					title: '提示',
					content: '确定接单吗？',
					success: function(res) {
						if (res.confirm) {
							let data = {
								ordersId: e.ordersId,
							}
							that.$Request.post("/app/orders/insertMyOrders", data).then(ret => {
								if (ret.code == 0) {
									uni.showToast({
										title: '接单成功',
										icon: 'none'
									})
									setTimeout(function() {
										uni.switchTab({
											url: '/pages/order/index'
										})
									}, 1000);
								} else {
									uni.showToast({
										title: ret.msg,
										icon: 'none'
									})
								}
							});
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			},
			goMsg() {
				let data = {
					userId: uni.getStorageSync('userId'),
					focusedUserId: this.order.user.userId
				}
				this.$Request.postJson('/app/chat/insertChatConversation ', data).then(res => {
					if (res.code == 0) {
						let id = this.order.user.userId == res.data.userId ? res.data.focusedUserId : this.order
							.user.userId
						uni.navigateTo({
							url: '/pages/msg/im?chatConversationId=' + res.data.chatConversationId +
								'&byUserId=' + id
						})
					}
				})
			},
		}
	}
</script>

<style>
	page {
		background: #f7f7f7;
	}

	.bg {
		background: #FFFFFF;
	}

	.tabber {
		width: 100%;
		background: #ffffff;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 99;
		justify-content: flex-end;
		height: 127rpx;
	}

	.boxtk {
		width: 100%;
		height: 162vh;
		background: rgba(0, 0, 0, 0.7);
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		z-index: 99;

	}

	.whitebox {
		width: 550upx;
		height: 440upx;
		background: #FFFFFF;
		border-radius: 32upx;
		margin: 0 auto;
		position: fixed;
		top: 450upx;
		left: 0;
		right: 0;
		z-index: 99;
	}

	.btn {
		/* width: 400upx; */
		height: 88upx;
		background: #557EFD;
		// box-shadow: 0upx 10upx 20upx 0upx #FFD9B3;
		border-radius: 16upx;
		margin: 0 auto;
		color: #fff;
		text-align: center;
		line-height: 88upx;
		margin-top: 43upx;
	}
</style>